﻿using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Events.Distributed;
using AbpVnext_Module.Validations;

namespace AbpVnext_Module.Dto
{
    public class PermissionCreateDto : EntityDto<int>   //, IValidatableObject  //自定义局部验证
    {
        /// <summary>
        /// 权限组
        /// </summary>
        public string PermissionGroup { get; set; }

        /// <summary>
        /// 权限值
        /// </summary>
        public string PermissionName { get; set; }

        ////验证字段不能为空
        //[Required]
        ////字段值长度验证
        //[StringLength(10)]
        //public string? OrderSn { get; set; }

        ///// <summary>
        ///// TotalPrice属性值必须包含123
        ///// </summary>
        //[Names("123")]
        //public string TotalPrice { get; set; }

        //[Range(99.99, 199.99)]
        //public decimal TotalDiscount { get; set; }

        ///// <summary>
        ///// 自定义验证(局部自定义)
        ///// </summary>
        ///// <param name="validationContext"></param>
        ///// <returns></returns>
        ///// <exception cref="NotImplementedException"></exception>
        //public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        //{
        //    if (OrderSn == TotalPrice)
        //    {
        //        yield return new ValidationResult("字段不能相等", new string[] { "OrderSn", "TotalPrice" });
        //    }
        //    yield break;
        //}
    }

    /// <summary>
    /// 
    /// </summary>
    public class DemoCreateDto
    {
        //验证字段不能为空
        [Required]
        //字段值长度验证
        [StringLength(10)]
        public string OrderSn { get; set; }

        public string TotalPrice { get; set; }

        /// <summary>
        /// 限制值范围
        /// </summary>
        [Range(0, 10)]
        public int Prece { get; set; }
    }
}
